-
Notifications
You must be signed in to change notification settings - Fork 458
Replace IMemoryMappedFileAccessor with null implementation #4573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@@ -84,6 +86,9 @@ public IServiceProvider ConfigureServices(IServiceCollection services) | |||
|
|||
services.AddWebJobsScriptHost(_builderContext.Configuration); | |||
|
|||
// Replace the default MemoryMappedFileAccessor with a null implementation | |||
services.Replace(ServiceDescriptor.Singleton<IMemoryMappedFileAccessor, NullMemoryMappedFileAccessor>()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fabiocav draft here; still need to consider all the potential impact of disabling this - let me know what you think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I think we still want to allow users to test this feature right? So maybe disable by default and add a flag to bring this back in. Or we just don't make a change here and fix it on the host side?
public override void Delete(string mapName, MemoryMappedFile mmf) | ||
{ | ||
Logger.LogDebug("NullMemoryMappedFileAccessor: Delete called for {MapName} - no action taken", mapName); | ||
mmf?.Dispose(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we care about mmf not being null or not already disposed?
/// A null implementation of MemoryMappedFileAccessor that disables shared memory functionality. | ||
/// This can be used for testing or in environments where shared memory is not supported or desired. | ||
/// </summary> | ||
public class NullMemoryMappedFileAccessor : MemoryMappedFileAccessor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seal it to prevent unintended extension.
Logger.LogDebug("Using NullMemoryMappedFileAccessor - shared memory data transfer is disabled"); | ||
} | ||
|
||
public override bool TryCreate(string mapName, long size, out MemoryMappedFile mmf) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a comment can help - "/// Always returns false; no shared memory is created. ///"
Issue describing the changes in this PR
resolves #issue_for_this_pr
Pull request checklist
release_notes.md
Additional information
Additional PR information